Previous topicNext topic
Help > Keyword Reference >
MOD operator

Purpose

Return the remainder of the division between two numbers.

Syntax

p MOD q

Remarks

The MOD operator divides the two operands, p and q, and returns the remainder of that division. The result of the initial division is truncated to an integral value, before the remainder is calculated. See the example below.

The remainder may be a floating point value. MOD is often considered to complement integral division.

See Also

LET

Example

lResult1& = 10& MOD 3&   ' Returns 1&

fResult2! = 13! MOD 2.7! ' Returns 2.2!

 

iStack&   = 1023&

HiStack& = iStack& \ 256&  ' Returns 3&

LoStack& = iStack& MOD 256 ' Returns 255&

 

' c! and d! are calculated equivalently

a! = 13

b! = 2.7

c! = a! MOD b!

d! = a! - FIX(a! / b!) * b!

 

CurrentLine = 1

WHILE CurrentLine < Lines

 PrintLine txt$(CurrentLine)

 IF (CurrentLine MOD 55) = 0 THEN DoFormFeed

 INCR CurrentLine

WEND